import config.Config;
import msg.MsgManager;
import net.TcpManager;
import net.UdpManager;
import use.FileUse;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class UpServer {
    public static void main(String[] args) {
        MsgManager.getInstance().rabbitInit();
        ScheduledExecutorService sche = Executors.newScheduledThreadPool(1);
        //每10秒扫描一次文件夹，对比之前的升级文件，新加文件就读取 删除文件就清除
        sche.scheduleAtFixedRate(()-> FileUse.getManager().read_folder(),0,10, TimeUnit.SECONDS);
        ExecutorService pool = Executors.newFixedThreadPool(3);
        pool.execute(()-> TcpManager.getInstance().run());
        pool.execute(()-> UdpManager.getInstance().run());
        pool.execute(()-> MsgManager.getInstance().msg_recv(Config.Rabbit_Recv_Queue));
        System.out.println("完成");
    }
}
